<template>
  <view>
     <block v-for="(item,index) in commentsList" :key="index">
       <commnetsCard :comments="item"/>
     </block>
    <u-loadmore :status="status" />
  </view>
</template>

<script>

import commnetsCard from "../../pagesB/components/commnetsCard";

export  default {
 async onLoad(option){
      this.shop_id = await option.shop_id
      this.getShopCommentList()
   uni.setNavigationBarTitle({
     title:this.$t('订单评价')
   });
  },
  data(){
      return{
        commentsList:[],
        page:1,
        shop_id:'',
        status:'loadmore'
      }
  },
  components:{
    commnetsCard
  },
  onReachBottom(){
      if(this.status !== 'nomore'){
          this.page++

          this.getShopCommentList()
      }
  },
  onPullDownRefresh(){
    this.page=1
      this.getShopCommentList()
  },
    methods:{
      getShopCommentList(){
      this.status='loading'
        const data = {
          shop_id:this.shop_id,
          page:this.page
        }
        this.$http.getShopCommentList(data).then(res=>{
        uni.stopPullDownRefresh()
          if(this.page===1){
            this.commentsList = res.data.comment_list
          }else{
            this.commentsList = this.commentsList.concat(res.data.comment_list)
          }
          if(res.data.comment_list.length<10){
            this.status = 'nomore'
          }
        })
      }
    }
}
</script>
